﻿<%@ Page Title="" Language="C#" MasterPageFile="~/BackEnd/BackEndMasterPage.Master" AutoEventWireup="true"
    CodeBehind="InsertUniversity.aspx.cs" Inherits="AteneoLibri.BackEnd.InsertUniversity" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Inserisci università
    </h2>
    <asp:Panel ID="pnlInsertCity" runat="server" DefaultButton="btnInsertUni">
        <h3>
            Inserisci la nuova università</h3>
        <div>
            <asp:TextBox ID="txtUniversity" runat="server" CssClass="StandardTextBox" ValidationGroup="vgInsertUni"></asp:TextBox>
            <div>
                <asp:RequiredFieldValidator ID="rfvUni" runat="server" ErrorMessage="* Campo obbligatorio"
                    ValidationGroup="vgInsertUni" ControlToValidate="txtUniversity" Display="Dynamic"
                    CssClass="failureNotification"></asp:RequiredFieldValidator>
            </div>
            Seleziona la nazione<br />
            <asp:DropDownList ID="ddlNations" runat="server" CssClass="StandardTextBox" DataTextField="Description"
                DataValueField="IdNation" ValidationGroup="vgInsertUni" AutoPostBack="true" AppendDataBoundItems="true"
                OnSelectedIndexChanged="ddlNations_SelectedIndexChanged">
                <asp:ListItem Selected="True" Enabled="true" Value="0">-- Seleziona --</asp:ListItem>
            </asp:DropDownList>
            <br />
            Seleziona la città<br />
            <asp:DropDownList ID="ddlCities" runat="server" CssClass="StandardTextBox" DataTextField="Description"
                DataValueField="IdCity" ValidationGroup="vgInsertUni">
            </asp:DropDownList>
            <br />
            <br />
            <asp:Button ID="btnInsertUni" runat="server" CssClass="StandardButton" Text="Inserisci"
                OnClick="btnInsertUni_Click" ValidationGroup="vgInsertUni" />
        </div>
    </asp:Panel>
    <div style="margin-top: 20px;">
        <h3>
            Elenco delle università inserite</h3>
        <asp:Panel ID="pnlUniversities" runat="server">
            <asp:GridView ID="gvUniversities" runat="server" EmptyDataText="Non ci sono università presenti nel database"
                AlternatingRowStyle-BackColor="#cccccc" BackColor="#ffffff" CellPadding="2" AutoGenerateColumns="false"
                ShowFooter="true" DataKeyNames="IdUniversity" PageSize="15" EmptyDataRowStyle-ForeColor="Red">
                <Columns>
                    <asp:BoundField HeaderText="Nome università" ReadOnly="true" DataField="Name" ItemStyle-Width="200px" />
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:Label ID="Label1" runat="server" Text="Città"></asp:Label>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblCity" runat="server" Text='<%# Bind("City") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:Label ID="Label2" runat="server" Text="Nazione"></asp:Label>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblNation" runat="server" Text='<%# Bind("Nation") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDeleteNation" runat="server" CssClass="metroButton" AlternateText="Cancella l'università"
                                ImageUrl="~/Images/deleteIcon.png" OnClick="btnDeleteUni_Click" CommandArgument='<%# Eval("IdUniversity") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </asp:Panel>
    </div>
</asp:Content>
